package com.qiujie.enums;

import com.qiujie.dto.ResponseDTO;

public enum ErrorEnum {
    PARAM_REQUIRED(400001, "必要参数缺失: %s"),
    PARAM_TYPE(400002, "参数类型错误: %s"),
    LEAVE_TYPE(400003, "无效请假类型: %s"),
    STAFF_CODE(400004, "无效工号"),
    STATUS_INVALID(400005, "非法审批状态"),
    SYSTEM_ERROR(500000, "系统异常"),
    LEAVE_STATUS(400006, "请假类型已停用: %s"),
    DUPLICATE_APPLY(400008, "存在未处理的申请"),
    SUBMIT_FAILED(500100, "申请提交失败"),
    STAFF_NOT_FOUND(400007, "员工不存在"),

    PARAM_INVALID(1003, "参数格式错误: {0}"),

    LEAVE_DAYS(3001, "请假天数超过限制，最大可申请天数：{0}"),
    ANNUAL_LEAVE_LIMIT(3002, "年假余额不足"),
    LEAVE_TYPE_DISABLED(3003, "该请假类型已被禁用"), UNAUTHORIZED(0,"用户未登录" );;

    private final int code;
    private final String template;

    ErrorEnum(int code, String template) {
        this.code = code;
        this.template = template;
    }

    public ResponseDTO toResponse(Object... args) {
        return new ResponseDTO(
                this.code,
                String.format(this.template, args)
        );
    }
}
